public virtual class RestClient {

	private String basePath;
	private String username;
	private String password;
	private HTTP h = new HTTP();
	public Boolean isTest = false;
	
	public void addCredentials(String startPath, String username, String password) {
		basePath = startPath;
		this.username = username;
		this.password = password;	
	}
	
	public virtual HttpResponse get(String path) {
    	HTTPRequest r = new HTTPRequest();
        r.setEndpoint(path);
        Blob headerValue = Blob.valueOf(username + ':' + password);
        String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
        r.setHeader('Authorization', authorizationHeader);
        r.setMethod('GET');
        if (!isTest) {
	        return h.send(r);
        } else {
        	return null;
        }
	}
	
	public virtual HttpResponse post(String path, String data) {
        HTTPRequest r = new HTTPRequest();
        r.setHeader('Content-Type', 'application/atom+xml');
        r.setEndpoint(path);
        Blob headerValue = Blob.valueOf(username + ':' + password);
        String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
        r.setHeader('Authorization', authorizationHeader);
        r.setMethod('POST');
        r.setBody(data);
        if (!isTest) {
	        return h.send(r);
        } else {
        	return null;
        }
	}
}